/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pv1682010;

import java.util.Date;

/**
 *
 * @author Isamaru
 */
public class Event implements Comparable<Event> {

    private Course course;
    private Integer eventNumber;
    private String eventName;
    private Date startDate;
    private Date endDate;

    public Event(Course course, String eventName, Date startDate, Date endDate) {
        this.course = course;
        this.eventNumber = null;
        this.eventName = eventName;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public Event(Course course, Integer eventNumber, String eventName, Date startDate, Date endDate) {
        this.course = course;
        this.eventNumber = eventNumber;
        this.eventName = eventName;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public Event() {
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public Integer getEventNumber() {
        return eventNumber;
    }

    public void setEventNumber(Integer eventNumber) {
        this.eventNumber = eventNumber;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Event other = (Event) obj;
        if (this.course != other.course && (this.course == null || !this.course.equals(other.course))) {
            return false;
        }
        if (this.eventNumber != other.eventNumber && (this.eventNumber == null || !this.eventNumber.equals(other.eventNumber))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 17 * hash + (this.course != null ? this.course.hashCode() : 0);
        hash = 17 * hash + (this.eventNumber != null ? this.eventNumber.hashCode() : 0);
        return hash;
    }

    public int compareTo(Event other) {
        int result = getCourse().compareTo(other.getCourse());
        if (result != 0) {
            return result;
        }
        return getEventNumber().compareTo(other.getEventNumber());
    }

    @Override
    public String toString() {
        return "Event from course: " + getCourse().getName() + " event name " + eventName + " with number " + eventNumber;
    }
}
